package pers.bbw.crr.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger文档配置类
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage("pers.bbw.crr"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo())
                .groupName("bbw");
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("校园资源预约网站后端接口文档")  // 标题
                .description("全部接口文档")  // 简介
                .termsOfServiceUrl("http://localhost:8080/api/") // Swagger API文档中的一个可选配置项，用于指定API服务的服务条款URL。
                .version("1.0")
                .build();
    }


}
